#include "ScnsTof10120.c.h"

#if defined(SCNS_TOF10120_ENABLE)&&SCNS_TOF10120_ENABLE==1

#include "ScnsIic.h"
#include "ScnsMenu.h"
#include "ScnsSmctpExtOscilloscope.h"

ScnsStatus scnsBspTof10120Init(ScnsTof10120Enum tofN)
{
    return SCNS_STATUS_OK;
}

ScnsStatus scnsBspTof10120PostInit(ScnsTof10120Enum tofN)
{
    scnsMenuSetPage(3,"Tof10120",NULL);
    scnsMenuAddConstStruct(3,scnsTof10120Result[tofN],distant,,SCNS_TYPE_UINT16);
    return SCNS_STATUS_OK;
}

static const uint8 device[SCNS_TOF10120_MAX]={0xA4};

ScnsStatus scnsBspTof10120Write(ScnsTof10120Enum tofN,const uint8*addr,uint8 addrLen,const uint8*data,uint8 dataLen)
{
    return scnsIicWrite(SCNS_IIC_SCL_B7_SDA_B6,device[tofN],addr,addrLen,data,dataLen);
}

ScnsStatus scnsBspTof10120Read(ScnsTof10120Enum tofN,const uint8*addr,uint8 addrLen,uint8*data,uint8 dataLen)
{
    return scnsIicRead(SCNS_IIC_SCL_B7_SDA_B6,device[tofN],addr,addrLen,data,dataLen);
}

void scnsBspTof10120ResultUpdate(ScnsTof10120Enum tofN)
{
    if(scnsMenuCanPageSend(3))
    {
        scnsSmctpExtOscilloscopeSend(SCNS_SMCTP_CHANNEL_VISUAL_SCOPE,SCNS_SMCTP_CHANNEL_VISUAL_SCOPE,
            scnsTof10120Result[tofN].distant,
        );
    }
    
}

#endif
